@echo off
chcp 65001 > nul 2>&1  # 解决中文乱码

:: 你的项目根路径（已固定为你的实际路径，无需修改）
set "PROJECT_ROOT=C:\Users\Windows10\Desktop\MAESS\maess_-flow"

:: 切换到项目根目录
cd /d "%PROJECT_ROOT%" || (
    echo ❌ 项目路径不存在！请确认路径是否正确：%PROJECT_ROOT%
    pause
    exit /b 1
)

echo 🚀 开始创建项目文件夹结构...

:: ==============================================
:: 1. 核心业务层：核心Agent（apps/）
:: ==============================================
md "apps\orchestrator" 2>nul
md "apps\text_qa" 2>nul
md "apps\doc_qa" 2>nul
md "apps\multi_modal" 2>nul
md "apps\tool_call" 2>nul

:: 编排Agent
type nul > "apps\orchestrator\__init__.py"
type nul > "apps\orchestrator\orchestrator_agent.py"
type nul > "apps\orchestrator\config.py"

:: 文本问答Agent
type nul > "apps\text_qa\__init__.py"
type nul > "apps\text_qa\text_qa_agent.py"
type nul > "apps\text_qa\tools.py"

:: DocQA Agent
type nul > "apps\doc_qa\__init__.py"
type nul > "apps\doc_qa\doc_qa_agent.py"
type nul > "apps\doc_qa\milvus_client.py"

:: 多模态Agent
type nul > "apps\multi_modal\__init__.py"
type nul > "apps\multi_modal\multi_modal_agent.py"
type nul > "apps\multi_modal\image_parser.py"

:: ToolCall Agent
type nul > "apps\tool_call\__init__.py"
type nul > "apps\tool_call\tool_call_agent.py"
type nul > "apps\tool_call\api_client.py"

:: ==============================================
:: 2. 辅助Agent层（auxiliary_agents/）
:: ==============================================
md "auxiliary_agents" 2>nul
type nul > "auxiliary_agents\__init__.py"
type nul > "auxiliary_agents\health_monitor.py"
type nul > "auxiliary_agents\compliance.py"
type nul > "auxiliary_agents\config_sync.py"

:: ==============================================
:: 3. State建模层（states/）
:: ==============================================
md "states" 2>nul
type nul > "states\__init__.py"
type nul > "states\agent_state.py"
type nul > "states\task_state.py"
type nul > "states\global_state.py"

:: ==============================================
:: 4. 通用工具集（tools/）
:: ==============================================
md "tools" 2>nul
type nul > "tools\__init__.py"
type nul > "tools\text_processing.py"
type nul > "tools\multimodal_processing.py"
type nul > "tools\middleware_ops.py"
type nul > "tools\security.py"
type nul > "tools\monitoring.py"

:: ==============================================
:: 5. 分布式保障模块（distributed/）
:: ==============================================
md "distributed" 2>nul
type nul > "distributed\__init__.py"
type nul > "distributed\circuit_breaker.py"
type nul > "distributed\rate_limiter.py"
type nul > "distributed\fallback.py"
type nul > "distributed\distributed_lock.py"

:: ==============================================
:: 6. 配置管理（config/）
:: ==============================================
md "config" 2>nul
type nul > "config\__init__.py"
type nul > "config\nacos_config.py"
type nul > "config\config_fallback.json"
type nul > "config\emergency_config.json"

:: ==============================================
:: 7. 中间件封装（middleware/）
:: ==============================================
md "middleware" 2>nul
type nul > "middleware\__init__.py"
type nul > "middleware\redis_client.py"
type nul > "middleware\nacos_client.py"
type nul > "middleware\milvus_client.py"

:: ==============================================
:: 8. API网关层（api_gateway/）
:: ==============================================
md "api_gateway\routers" 2>nul
md "api_gateway\middleware" 2>nul
type nul > "api_gateway\__init__.py"
type nul > "api_gateway\app.py"
type nul > "api_gateway\routers\__init__.py"
type nul > "api_gateway\routers\search.py"
type nul > "api_gateway\routers\status.py"
type nul > "api_gateway\middleware\__init__.py"
type nul > "api_gateway\middleware\auth.py"
type nul > "api_gateway\middleware\rate_limiter.py"

:: ==============================================
:: 9. 通用辅助工具（utils/）
:: ==============================================
md "utils" 2>nul
type nul > "utils\__init__.py"
type nul > "utils\logger.py"
type nul > "utils\constants.py"
type nul > "utils\exceptions.py"

:: ==============================================
:: 10. 运维部署（deploy/）
:: ==============================================
md "deploy\k8s" 2>nul
md "deploy\scripts" 2>nul
type nul > "deploy\docker-compose.yml"
type nul > "deploy\scripts\health_check.bat"
type nul > "deploy\scripts\deploy.bat"

:: ==============================================
:: 11. 项目核心文件（已存在则跳过，避免覆盖）
:: ==============================================
if not exist "requirements.txt" type nul > "requirements.txt"
if not exist "main.py" type nul > "main.py"
if not exist "docker-compose.yml" type nul > "docker-compose.yml"

:: 输出成功提示
echo.
echo ✅ 项目文件夹结构创建完成！
echo 📁 项目路径：%PROJECT_ROOT%
echo.
echo 💡 下一步操作：
echo  1. 打开项目：用PyCharm/VS Code打开 %PROJECT_ROOT%
echo  2. 安装依赖：在终端执行 pip install -r requirements.txt
echo  3. 启动服务：在终端执行 python main.py
echo  4. 容器化部署：cd deploy && docker-compose up -d（需安装Docker）
echo.

pause